import request from '@/utils/request'
import {encodeParams} from '@/utils'


// 列表查询
export function getPage(data) {
  return request({
    url: '/api/productType?${encodeParams(data)}',
    method: 'POST',
    data
  })
}

// 创建
export function create(data) {
  return request({
    url: '/api/productType/create',
    method: 'POST',
    data
  })
}


//启用禁用
export function changeEnable(id, enable) {
  return request({
    url: `/api/productType/enable/${id}/${enable}`,
    method: 'GET',
  })
}

//根据id查询
export function getById(id) {
  return request({
    url: `/api/productType/get/${id}`,
    method: 'GET',
  })
}

//根据id删除
export function deleteById(id) {
  return request({
    url: `/api/productType/item/delete/${id}`,
    method: 'GET',
  })
}
///productType/item/saveSort
//sort
export function saveSort(data) {
  return request({
    url: `/api/productType/item/saveSort`,
    method: 'POST',
    data
  })
}
//更新
export function update(data) {
  return request({
    url: '/api/productType/update',
    method: 'POST',
    data
  })
}

//版块商品分页查询
export function getItems(data) {
  return request({
    url: '/api/productType/item?${encodeParams(data)}',
    method: 'POST',
    data
  })
}

//版块商品分页保存
export function batchSave(data) {
  return request({
    url: '/api/productType/item/batchSave',
    method: 'POST',
    data
  })
}

export default {
  getPage, create, update, deleteById, getById, changeEnable,getItems,batchSave,saveSort
}
